import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class UserListItemWidget extends StatefulWidget {
  // final SimpleChannelUser user;
  final VoidCallback? onPressed;
  final int index;

  ///1贡献榜 2在线观众
  final int tabIndex;

  const UserListItemWidget(
      {Key? key,
      // required this.user,
      required this.index,
      this.onPressed,
      this.tabIndex = 0})
      : super(key: key);

  @override
  State<UserListItemWidget> createState() => _UserListItemWidgetState();
}

class _UserListItemWidgetState extends State<UserListItemWidget> {
  bool isTapping = false;

  @override
  Widget build(BuildContext context) {
    bool showIcon = (widget.tabIndex == 1) && (widget.index <= 2);
    return CupertinoButton(
      onPressed: () {
        widget.onPressed?.call();
      },
      minSize: 0,
      padding: EdgeInsets.zero,
      child: Container(
        decoration: const BoxDecoration(
          color: Colors.white,
        ),
        padding: const EdgeInsets.only(left: 2, right: 20, top: 20),
        height: 72,
        child: Row(
          children: [
            Container(
              width: 64,
              alignment: AlignmentDirectional.center,
              child: showIcon
                  ? Image.asset(
                      "assets/images/ic_room_top_${widget.index + 1}.png",
                      width: 24,
                      height: 19,
                      fit: BoxFit.contain)
                  : Text(
                      "${widget.index + 1}",
                      style: TextStyle(
                          fontSize: 20,
                          color: isTapping
                              ? Colors.white
                              : const Color(0xff666666),
                          fontWeight: FontWeight.w600,
                          height: 1),
                    ),
            ),
            // AvatarImage(
            //     url: widget.user.avatar,
            //     width: 50,
            //     height: 50,
            //     borderRadius: 25),
            const SizedBox(
              width: 10,
            ),
            const Expanded(
              child: Column(
                  mainAxisSize: MainAxisSize.min,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Row(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Text(
                          'nickname',
                          maxLines: 1,
                          style: TextStyle(
                              overflow: TextOverflow.ellipsis,
                              fontSize: 13,
                              color: Color(0xff333333),
                              fontWeight: FontWeight.w500),
                        ),
                        SizedBox(
                          width: 4,
                        ),
                        // SexAgeLabel(
                        //   isMale: widget.user.gender == UserConstants.genderMan,
                        //   age: widget.user.age.toString(),
                        // )
                      ],
                    ),
                    SizedBox(
                      height: 4,
                    ),
                    // Row(
                    //   children: [
                    //     UserLevWidget(
                    //       vipImgStr: widget.user.vipIcons.middleIcon,
                    //     ),
                    //     UserCarLevelWidget(
                    //       carLevel: widget.user.car.carMetaInfo.level,
                    //       job: widget.user.job,
                    //     ),
                    //   ],
                    // ),
                  ]),
            ),
            const SizedBox(
              width: 10,
            ),
            if (widget.tabIndex == 1)
              const Text(
                "contributionValue",
                style: TextStyle(
                    fontSize: 15,
                    fontWeight: FontWeight.w500,
                    color: Color(0xff333333)),
              ),
          ],
        ),
      ),
    );
  }
}
